package com.test.languagetest;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;

import com.pojo.Product;

public class HibernateTestStatus {
	
	public static void main(String[] args) {
		
		SessionFactory sf = new Configuration().configure().buildSessionFactory();
		Session s = sf.openSession();
		s.beginTransaction();
		
		Product p = new Product();
		p.setName("hibernate 状态演示！");
		System.out.println("此时p是瞬时状态！");
		
		s.save(p);
		System.out.println("此时是持久状态！");
		
		s.getTransaction().commit();
		s.close();
		System.out.println("此时是托管状态！");
		sf.close();
	}
}
